//Sat May 28 10:50:51 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class CubeAnts {
public:
	int getMinimumSteps(vector<int> pos) {
		int N = pos.size();
		int mmax = 0;
		for (int i = 0; i < N; i++) {
			mmax = max(mmax, getStep(pos[i]));
		}
		return mmax;
	}
	int getStep(int p) {
		switch (p) {
		case 0:
			return 0;
		case 1:
			return 1;
		case 2:
			return 2;
		case 3:
			return 1;
		case 4:
			return 1;
		case 5:
			return 2;
		case 6:
			return 3;
		case 7:
			return 2;
		default:
			return 0;
		}
	}
};

